import csv
from faker import Faker
fake = Faker('zh_CN')

# 银行名称列表
bank_names = ['中国工商银行', '中国农业银行', '中国交通银行', '中国建设银行']

# 生成数据
data = []
for i in range(500):
    for j in range(4):
        # 随机选择一个银行名称
        bank_name = bank_names[j]

        # 随机生成银行卡类型
        card_type = fake.random_int(min=1, max=2)

        # 生成银行卡号
        card_number = fake.credit_card_number()

        data.append([bank_name, card_type, card_number, '100'])

# 写入CSV文件
with open('data_card.csv', 'w', newline='', encoding='utf-8') as file:
    writer = csv.writer(file)
    writer.writerows(data)

print('数据已保存到data_card.txt文件中')
